package com.itheima.TCP;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo02 {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10086);
        Socket socket = serverSocket.accept();
        InputStream is = socket.getInputStream();
        //用转换流将字节流转为字符缓冲流
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String s = br.readLine();
        System.out.println(s);

        OutputStream os = socket.getOutputStream();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
        bw.write("我不认识你啊");
        bw.newLine();
        bw.flush();

        bw.close();
        socket.close();
        serverSocket.close();
    }
}
